package com.woniuxy.config;

import com.woniuxy.entity.MyClazz;
import com.woniuxy.entity.Student;
import com.woniuxy.entity.Teacher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class getBean {
    //获取老师的bean对象
    @Bean
    public Teacher teacher(){
        return new Teacher("雷老c");
    }

    //获取学生集合
    @Bean
    public List<Student> productionStudents(){
        List<Student> list = new ArrayList<>();
        list.add(new Student("苏寅洪"));
        list.add(new Student("邓云溪"));
        list.add(new Student("许泊宁"));
        return list;
    }

    //获取班级对象
    @Bean
    public MyClazz getClazz(Teacher teacher,List<Student> list){
        MyClazz myClazz = new MyClazz();
        myClazz.setTeacher(teacher);
        myClazz.setName("86期");
        myClazz.setStudents(list);
        return myClazz;
    }
}
